package com.flyduck.system.vo.menu.trans;


import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ObjectUtil;
import com.flyduck.system.entity.SysMenuEntity;
import com.flyduck.system.vo.menu.SysMenuDetailRespVO;
import com.google.common.base.Function;


/**
 * @program: flyduck-platform
 * @description:
 * @author: flyduck
 * @create: 2021-02-01 12:42
 **/
public class SysMenuEntityToSysMenuDetailRespVO implements Function<SysMenuEntity, SysMenuDetailRespVO> {

    @Override
    public SysMenuDetailRespVO apply(SysMenuEntity entity) {
        SysMenuDetailRespVO sysMenuDetailRespVO = new SysMenuDetailRespVO();
        BeanUtil.copyProperties(entity,sysMenuDetailRespVO);
        sysMenuDetailRespVO.setId(entity.getId()+"");
        if(ObjectUtil.isNotNull(entity.getParentId())){
            sysMenuDetailRespVO.setParentId(entity.getParentId()+"");
        }
        sysMenuDetailRespVO.setSort(String.valueOf(entity.getSort()));
        return sysMenuDetailRespVO;
    }
}
